package org.example.utils;

import lombok.Data;

@Data
public class R<T> {
    public static <T> R ok(int code,String msg,T data){
        R r = new R();
        r.code = code;
        r.msg = msg;
        r.data = data;
        return r;
    }
    public static <T> R ok(int code,T data){
        return ok(code,"操作成功",data);
    }
    public static <T> R ok(T data){
        return ok(200,data);
    }
    public static R fail(int code,String msg){
        R r = new R();
        r.code = code;
        r.msg = msg;
        return r;
    }
    public static R ok(String msg){
        return R.ok(200,msg,null);
    }
    public static R fail(String msg){
        return fail(500,msg);
    }
    private int code;
    private String msg;
    private T data;
}
